import { h } from 'vue';
import { Button, Tag } from 'ant-design-vue';
import { ValueEnum } from '../../types/index';

enum Colors {
  success = 'success',
  primary = 'processing',
  danger = 'error',
  warning = 'warning',
  default = 'default',
  info = 'default',
}

export const defaultProvide = {
  renderStatus: (opt: ValueEnum[keyof ValueEnum]) => {
    return h(
      Tag,
      { color: Colors[opt.status as keyof typeof Colors] },
      { default: () => opt.text },
    );
  },
  renderSearchButton: ({ key, ...otherProps }: any) => {
    switch (key) {
      case 'search':
        return h(
          Button,
          { type: 'primary', ...otherProps },
          { default: () => '搜索' },
        );
      case 'reset':
        return h(Button, { ...otherProps }, { default: () => '重置' });
      case 'expand':
        return h(Button, { ...otherProps }, { default: () => '展开' });
      case 'collapse':
        return h(Button, { ...otherProps }, { default: () => '收起' });
      default:
        return h(Button, { ...otherProps }, { default: () => 'click me' });
    }
  },
  searchConfigProvider: {},
  toolbarsConfigProvider: {},
  formModalConfigProvider: {},
  showFormModalResultMessage: false,
};
